home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9963 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: susx.ac.uk!mattst
  2. From: mattst@cogs.susx.ac.uk (Matthew Stanfield)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: C coding standards
  5. Date: 14 Mar 1996 17:45:36 GMT
  6. Organization: University of Sussex
  7. Distribution: world
  8. Message-ID: <4i9m00$aqi@infa.central.susx.ac.uk>
  9. References: <313B4548.45AA@oc.com> <DnuLzM.8xr@gti-ia.nl>
  10. NNTP-Posting-Host: tsunx.ctn.cogs.susx.ac.uk
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Paul Wallis (paulw@gti-ia.nl) wrote:
  14. : Teresa Reiko wrote:
  15. : > In this book and others, notably 'Code Complete', these programming
  16. : > guides published by Microsoft Press, it is evident why Microsoft put
  17. : > so many bugs in Windows 95.  Here are the three worst Microsoft
  18. : > coding rules, in my opinion at least:
  19. : >
  20. : > Every line of code must contain a comment.
  21. : > Any number greater than 2 must be a named constant.
  22. : > No procedure may be longer than 25 lines.
  23. : >
  24. : > If you follow these rules, you can be sure to write buggy, inefficient
  25. : > code that is difficult to revise and will generally look 'dirty'.
  26. : > Of course, if this is your intent, that's OK, but...
  27. : >
  28. : I am sorry, but I feel compelled to answer this, even though the debate does NOT
  29. : belong in this newsgroup.  I believe IMHO that you have maligned an excellent book.
  30. : I have read this book cover to cover and agreed with 90% of what the author says.
  31. : And before you go on to 'slate' me, I think you aught to re-read the book and actually
  32. : look at what is said.
  33.  
  34. : The Code Complete definately does not say that every line should have a comment.
  35. : In fact it says that you should be able to read what the code is meant to do without
  36. : resorting to comments every line.  The author tries to put across the idea that
  37. : comments bear a purpose and are not a cross to be born.
  38.  
  39. : It suggests that a _guideline_ to function length would be one page long; going on
  40. : to say that a page could be 25 lines 60 lines or even 120 lines depending upon wha
  41. : you use for display.
  42.  
  43. : As for ridiculing the fact that numbers greater than 2 should be a named constant.
  44. : I really can't see your argument there.  It has, as far as I'm aware, always been
  45. : common practice in the 'C' programming community to write:
  46.  
  47. :     #define NAME_LIMIT 39
  48. :     char    name[NAME_LIMIT];
  49.  
  50. : as opposed to:
  51.  
  52. :     char    name[39];
  53.  
  54. : And IMHO the former is far easier to read an when you wish to upgrade or modify the
  55. : length of a name you only have to change the #define as opposed to searching through
  56. : all of your code for the number 39 and doing a replace...
  57.  
  58. : Regards,
  59. :     Paul
  60.  
  61. Listen to what Paul says Teresa, he knows what he's talking about.
  62.  
  63. As for Code Complete -- it rules okay, you should re-read and think about
  64. why what he says is sound. From what you've said I bet you've never maintained
  65. anybody else's code and wished that they had read Code Complete.
  66.  
  67. BTW did you do a CS or similar degree? No - what a surprise.
  68.  
  69. Matt
  70.  
  71.     |------------------------------------------------|
  72.     |   ,\\///,    Matthew  Stanfield       ,\\\//,  |
  73.     |    O | O     Cognitive Sciences        O | O   |
  74.     |      |      University of Sussex         |     |
  75.     |    \-+-/   mattst@cogs.susx.ac.uk      \-+-/   |
  76.     |------------------------------------------------|
  77.